﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NPuzzles_dynamiczne_kontrolki
{
    public partial class Form1 : Form
    {
        MyPictureBoxesContainer ukladanka;

        public Form1()
        {
            InitializeComponent();
        }

        private void poczatkujacyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ukladanka = new MyPictureBoxesContainer(this.pictureBox1.Image, 3);
            ukladanka.CreatePuzzle();
            ukladanka.RandomizePuzzle();
            this.pictureBox1.Visible = false;
        }

        private void WczytajObrazek()
        {
            OpenFileDialog obrazek = new OpenFileDialog();
            obrazek.Filter = "jpg |*.jpg";
            obrazek.Multiselect = false;
            obrazek.ShowDialog();
            if (obrazek.FileName != "")
            {
                this.pictureBox1.Load(obrazek.FileName);
                this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            else
            {
                Application.Exit();
            }
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {

        }

        private void otworzToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WczytajObrazek();
        }

        private void zaawansowanyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ukladanka = new MyPictureBoxesContainer(this.pictureBox1.Image, 4);
            ukladanka.CreatePuzzle();
            ukladanka.RandomizePuzzle();
            this.pictureBox1.Visible = false;
        }
    }
}
